package com.xuerhua.yxt;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.xuerhua.yxt.utils.HttpClientUtils;
import com.xuerhua.yxt.utils.TextUtil;
import com.xuerhua.yxt.wechat.message.FirstButtonMenu;
import com.xuerhua.yxt.wechat.message.MenuList;
import com.xuerhua.yxt.wechat.message.SubButtonMenu;


public class PushMenuService {
	
	public static void main(String[] args) {
		menu20170222();
	}
	
	public static void menu20160115() {
		MenuList menuList = new MenuList();
		List<FirstButtonMenu> firstButtonMenus = new ArrayList<>();
		
		List<SubButtonMenu> subButtonMenus = new ArrayList<>();
		FirstButtonMenu firstButtonMenu = new FirstButtonMenu();
		firstButtonMenu.setName("🌏学校");
		SubButtonMenu subButtonMenu = new SubButtonMenu();
		subButtonMenu.setType("scancode_waitmsg");
		subButtonMenu.setName("扫码带提示");
		subButtonMenu.setKey("rselfmenu_0_0");
//		subButtonMenus.add(subButtonMenu);
		SubButtonMenu subButtonMenu1 = new SubButtonMenu();
		subButtonMenu1.setType("scancode_push");
		subButtonMenu1.setName("扫码推事件");
		subButtonMenu1.setKey("rselfmenu_0_1");
//		subButtonMenus.add(subButtonMenu1);
		SubButtonMenu subButtonMenu02 = new SubButtonMenu();
		subButtonMenu02.setType("view");
		subButtonMenu02.setName("校辅实践");
		subButtonMenu02.setUrl("http://mp.weixin.qq.com/s/_bjOQwWFy4M3UBgOyECzsw");
		subButtonMenus.add(subButtonMenu02);
		SubButtonMenu subButtonMenu03 = new SubButtonMenu();
		subButtonMenu03.setType("view");
		subButtonMenu03.setName("学科探究");
		subButtonMenu03.setUrl("http://mp.weixin.qq.com/s/IA8xTeOidtw89ilqOLBZrA");
		subButtonMenus.add(subButtonMenu03);
		SubButtonMenu subButtonMenu04 = new SubButtonMenu();
		subButtonMenu04.setType("view");
		subButtonMenu04.setName("STEAM创客实践");
		subButtonMenu04.setUrl("");
//		subButtonMenus.add(subButtonMenu04);
		SubButtonMenu subButtonMenu05 = new SubButtonMenu();
		subButtonMenu05.setType("view");
		subButtonMenu05.setName("营地教育");
		subButtonMenu05.setUrl("http://mp.weixin.qq.com/s/XrzT92mO3BgJSCMNquMO8Q");
		subButtonMenus.add(subButtonMenu05);
		SubButtonMenu subButtonMenu07 = new SubButtonMenu();
		subButtonMenu07.setType("view");
		subButtonMenu07.setName("STEAM创客");
		subButtonMenu07.setUrl("http://mp.weixin.qq.com/s/kcUP6k8YkP6MDpNEkMBE8A");
		subButtonMenus.add(subButtonMenu07);
		SubButtonMenu subButtonMenu06 = new SubButtonMenu();
		subButtonMenu06.setType("view");
		subButtonMenu06.setName("关于我们");
		subButtonMenu06.setUrl("http://mp.weixin.qq.com/s/F4eDKmVwmYXGCtubGVUrMw");
		subButtonMenus.add(subButtonMenu06);
		
		firstButtonMenu.setSub_button(subButtonMenus);
		firstButtonMenus.add(firstButtonMenu);
		
		
		FirstButtonMenu firstButtonMenu2 = new FirstButtonMenu();
		firstButtonMenu2.setName("发图");
		List<SubButtonMenu> subButtonMenus2 = new ArrayList<>();
		SubButtonMenu subButtonMenu3 = new SubButtonMenu();
		subButtonMenu3.setType("pic_sysphoto");
		subButtonMenu3.setName("系统拍照发图");
		subButtonMenu3.setKey("rselfmenu_1_0");
		subButtonMenus2.add(subButtonMenu3);
		SubButtonMenu subButtonMenu4 = new SubButtonMenu();
		subButtonMenu4.setType("pic_photo_or_album");
		subButtonMenu4.setName("拍照或者相册发图");
		subButtonMenu4.setKey("rselfmenu_1_1");
		subButtonMenus2.add(subButtonMenu4);
		firstButtonMenu2.setSub_button(subButtonMenus2);
//		firstButtonMenus.add(firstButtonMenu2);
		
		FirstButtonMenu firstButtonMenu3 = new FirstButtonMenu();
		firstButtonMenu3.setName("发送位置");
		firstButtonMenu3.setType("location_select");
		firstButtonMenu3.setKey("rselfmenu_2_0");
//		firstButtonMenus.add(firstButtonMenu3);
		
		FirstButtonMenu firstButtonMenu4 = new FirstButtonMenu();
		firstButtonMenu4.setName("📡图文消息");
		firstButtonMenu4.setType("click");
		firstButtonMenu4.setKey("rselfmenu_3_0");
		firstButtonMenus.add(firstButtonMenu4);
		
		FirstButtonMenu firstButtonMenu5 = new FirstButtonMenu();
		firstButtonMenu5.setName("📷直播");
		firstButtonMenu5.setType("view");
		firstButtonMenu5.setUrl("http://m.xue110.top/live");
		firstButtonMenus.add(firstButtonMenu5);
		
		menuList.setButton(firstButtonMenus);
		
		pushMenu(menuList);
	}
	
	public static void menu20170222() {
		MenuList menuList = new MenuList();
		List<FirstButtonMenu> firstButtonMenus = new ArrayList<>();
		
		FirstButtonMenu firstButtonMenu01 = new FirstButtonMenu();
		List<SubButtonMenu> subButtonMenus01 = new ArrayList<>();
		firstButtonMenu01.setName("🏩学校");
		
//		SubButtonMenu subButtonMenu005 = new SubButtonMenu();
//		subButtonMenu005.setName("操作手册");
//		subButtonMenu005.setType("view");
//		subButtonMenu005.setUrl("http://mp.weixin.qq.com/mp/homepage?__biz=MjM5NzU2OTIxMg==&hid=1&sn=614b96a6026efdcfe191d321175f3003#wechat_redirect");
//		subButtonMenus01.add(subButtonMenu005);
		
		SubButtonMenu subButtonMenu001 = new SubButtonMenu();
		subButtonMenu001.setName("盛世迎华诞");
		subButtonMenu001.setType("view");
		subButtonMenu001.setUrl("https://mp.weixin.qq.com/s/LY1ieLXXPYASBLsY2pNWcQ");
		subButtonMenus01.add(subButtonMenu001);
		
		SubButtonMenu subButtonMenu002 = new SubButtonMenu();
		subButtonMenu002.setName("开门迎学子");
		subButtonMenu002.setType("view");
		subButtonMenu002.setUrl("https://mp.weixin.qq.com/s/aQ0Tk4zISROjeW2npC83Hw");
		subButtonMenus01.add(subButtonMenu002);
		
		SubButtonMenu subButtonMenu003 = new SubButtonMenu();
		subButtonMenu003.setName("校园开放日");
		subButtonMenu003.setType("view");
		subButtonMenu003.setUrl("https://mp.weixin.qq.com/s/bgwW6-p_n1lt0P13YDR9xQ");
		subButtonMenus01.add(subButtonMenu003);
		
		
//		SubButtonMenu subButtonMenu001 = new SubButtonMenu();
//		subButtonMenu001.setName("学校介绍");
//		subButtonMenu001.setType("view");
//		subButtonMenu001.setUrl("http://mp.weixin.qq.com/s/X_9RBOazhY1r_j0Z2e4g3g");
//		subButtonMenus01.add(subButtonMenu001);
//		
//		SubButtonMenu subButtonMenu002 = new SubButtonMenu();
//		subButtonMenu002.setName("学校地图定位");
//		subButtonMenu002.setType("view");
//		subButtonMenu002.setUrl("http://map.baidu.com/mobile/webapp/place/detail/qt=inf&uid=f1c4cda3f177e10f1676439e/shareurl=1&da_from=weixin&openna=1&t=1496561666&vt=map");
//		subButtonMenus01.add(subButtonMenu002);
//		
//		SubButtonMenu subButtonMenu003 = new SubButtonMenu();
//		subButtonMenu003.setName("培立实验小学网站");
//		subButtonMenu003.setType("view");
//		subButtonMenu003.setUrl("http://smfx.nhedu.net/");
//		subButtonMenus01.add(subButtonMenu003);
//		
//		SubButtonMenu subButtonMenu004 = new SubButtonMenu();
//		subButtonMenu004.setName("教育教学开放日");
//		subButtonMenu004.setType("view");
//		subButtonMenu004.setUrl("http://smfx.nhedu.net/kaifangri/");
//		subButtonMenus01.add(subButtonMenu004);
		
//		SubButtonMenu subButtonMenu002 = new SubButtonMenu();
//		subButtonMenu002.setName("招生简章");
//		subButtonMenu002.setType("view");
//		subButtonMenu002.setUrl("http://mp.weixin.qq.com/s/UyUcVf2XvXlwbyW8zsFIiw");
//		subButtonMenus01.add(subButtonMenu002);
		
		/*SubButtonMenu subButtonMenu003 = new SubButtonMenu();
		subButtonMenu003.setName("新生报名");
		subButtonMenu003.setType("view");
		subButtonMenu003.setUrl("http://yxt.smfx.org/common/signUp/newStu");
		subButtonMenus01.add(subButtonMenu003);
		
		SubButtonMenu subButtonMenu004 = new SubButtonMenu();
		subButtonMenu004.setName("插班生报名");
		subButtonMenu004.setType("view");
		subButtonMenu004.setUrl("http://yxt.smfx.org/common/signUp/middleStu");
		subButtonMenus01.add(subButtonMenu004);
		
		SubButtonMenu subButtonMenu005 = new SubButtonMenu();
		subButtonMenu005.setName("国际班报名");
		subButtonMenu005.setType("view");
		subButtonMenu005.setUrl("http://yxt.smfx.org/common/signUp/internatStu");
		subButtonMenus01.add(subButtonMenu005);
		
		SubButtonMenu subButtonMenu006 = new SubButtonMenu();
		subButtonMenu006.setName("教师招聘报名");
		subButtonMenu006.setType("view");
		subButtonMenu006.setUrl("http://yxt.smfx.org/common/signUp/teacher");
		subButtonMenus01.add(subButtonMenu006);*/
		
		firstButtonMenu01.setSub_button(subButtonMenus01);
		firstButtonMenus.add(firstButtonMenu01);
		
		FirstButtonMenu firstButtonMenu02 = new FirstButtonMenu();
		firstButtonMenu02.setName("教师");
		firstButtonMenu02.setType("view");
		firstButtonMenu02.setUrl("http://peili.xuerhua.com/ls");
		firstButtonMenus.add(firstButtonMenu02);
		/*List<SubButtonMenu> subButtonMenus = new ArrayList<>();
		FirstButtonMenu firstButtonMenu = new FirstButtonMenu();
		firstButtonMenu.setName("🐝教师");
		SubButtonMenu subButtonMenu02 = new SubButtonMenu();
		subButtonMenu02.setType("view");
		subButtonMenu02.setName("班级相册");
		subButtonMenu02.setUrl("http://yxt.smfx.org/ls/album/class");
		subButtonMenus.add(subButtonMenu02);
		SubButtonMenu subButtonMenu03 = new SubButtonMenu();
		subButtonMenu03.setType("view");
		subButtonMenu03.setName("班级通知");
		subButtonMenu03.setUrl("http://yxt.smfx.org/ls/notice/class");
		subButtonMenus.add(subButtonMenu03);
		SubButtonMenu subButtonMenu05 = new SubButtonMenu();
		subButtonMenu05.setType("view");
		subButtonMenu05.setName("我的工具");
		subButtonMenu05.setUrl("http://yxt.smfx.org/ls");
		subButtonMenus.add(subButtonMenu05);
		firstButtonMenu.setSub_button(subButtonMenus);
		firstButtonMenus.add(firstButtonMenu);*/
		
		/*FirstButtonMenu firstButtonMenu02 = new FirstButtonMenu();
		List<SubButtonMenu> subButtonMenus02 = new ArrayList<>();
		firstButtonMenu02.setName("🐝教师");
		
		SubButtonMenu subButtonMenu021 = new SubButtonMenu();
		subButtonMenu021.setName("教师主页");
		subButtonMenu021.setType("view");
//		subButtonMenu001.setKey("rselfmenu_3_0");
		subButtonMenu021.setUrl("http://yxt.smfx.org/ls");
		subButtonMenus02.add(subButtonMenu021);
		
		SubButtonMenu subButtonMenu022 = new SubButtonMenu();
		subButtonMenu022.setName("上班签到");
		subButtonMenu022.setType("view");
		subButtonMenu022.setUrl("http://yxt.smfx.org/ls/work/cardSign");
		subButtonMenus02.add(subButtonMenu022);*/
		
		/*firstButtonMenu02.setSub_button(subButtonMenus02);
		firstButtonMenus.add(firstButtonMenu02);*/
		
		FirstButtonMenu firstButtonMenu03 = new FirstButtonMenu();
		firstButtonMenu03.setName("家长");
		firstButtonMenu03.setType("view");
		firstButtonMenu03.setUrl("http://peili.xuerhua.com/xs");
		firstButtonMenus.add(firstButtonMenu03);
		
		menuList.setButton(firstButtonMenus);
		
		pushMenu(menuList);
	}
	
	public static void menu20170407() {
		MenuList menuList = new MenuList();
		List<FirstButtonMenu> firstButtonMenus = new ArrayList<>();
		
		FirstButtonMenu firstButtonMenu01 = new FirstButtonMenu();
		firstButtonMenu01.setName("🌏趣介绍");
		firstButtonMenu01.setType("view");
		firstButtonMenu01.setUrl("http://mp.weixin.qq.com/s/F4eDKmVwmYXGCtubGVUrMw");
		firstButtonMenus.add(firstButtonMenu01);
		
		FirstButtonMenu firstButtonMenu02 = new FirstButtonMenu();
		firstButtonMenu02.setName("📚趣直播");
		firstButtonMenu02.setType("view");
		firstButtonMenu02.setUrl("http://m.xue110.top/live");
		firstButtonMenus.add(firstButtonMenu02);
		
		FirstButtonMenu firstButtonMenu03 = new FirstButtonMenu();
		firstButtonMenu03.setName("📚趣报名");
		firstButtonMenu03.setType("view");
		firstButtonMenu03.setUrl("http://m.xue110.top/course");
		firstButtonMenus.add(firstButtonMenu03);
		menuList.setButton(firstButtonMenus);
		
		pushMenu(menuList);
	}
	
	private static void pushMenu(MenuList menuList) {
		try {
			String acc = "26_OS7598Rs1rhwNxjixRKIEvXpOXp99XeH1Sf8g20_r5td-CKgi1lWnjUrFQ54aaakY0TQ5Sbe_nU9SM-tmZ6gmd4Stv3uDHjLAnRmdJ557mLJ37c_vBFKpV5WL1feQHqK3nITS8nWiPChHYkQCJOcAAARYD";//WechatUtils.getWechatModel().getAccessToken();
			String json = JSONObject.toJSONString(menuList);
			String url = TextUtil.format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", acc);
			String result = HttpClientUtils.postStringJosn(url, json);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
